package com.jhc.yolo_web.service;

import ai.onnxruntime.OrtException;
import com.jhc.yolo.Runner;
import com.jhc.yolo.pojo.ModelConfig;
import com.jhc.yolo_web.config.YoloConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Service
public class YoloService {

    private static Runner runner;
    @Autowired
    public void setRunner(YoloConfig config) throws IOException, OrtException {
        YoloService.runner = new Runner(config);
    }

    public String detection(MultipartFile file) throws IOException, OrtException {
        String savePath = "E:\\test\\" + file.getOriginalFilename();
        return runner.detection(file.getBytes(),savePath);
    }

}
